package com.qf.mybatisplus.config.rabbitMQConfig;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class DLXConfig {

    /**
     * 死信队列配置
     * @return
     */

    // DirectExchange 类型的交换机
    @Bean
    public DirectExchange dlxDirectExchange(){
        return new DirectExchange(RabbitMQCommonConfig.DLX_DIRECT_EXCHANGE);
    }

    @Bean
    public Queue dlxDirectQueue(){
        return new Queue(RabbitMQCommonConfig.DLX_DIRECT_QUEUE,true,false,false);
    }


    @Bean
    public Binding dlxDirectBinding(){
        return BindingBuilder.bind(dlxDirectQueue()).to(dlxDirectExchange()).with(RabbitMQCommonConfig.DLX_DIRECT_ROUTINGKEY);
    }
}
